package com.erp.framework.util.excelupload;

import java.sql.Connection;
import java.util.ArrayList;

import com.erp.framework.util.logger.Logger;

public class ExcelRowFactory {
	private ExcelRowVo protoRowVo;
	private static ExcelRowFactory instance = new ExcelRowFactory();
	
	private ExcelRowFactory(){
	}
	
	public static ExcelRowFactory getInstance(){
		if(instance==null){
			instance = new ExcelRowFactory();
		}
		return instance;
	}
	
	public void initProtoExcelRow(Connection conn){
		ExcelRowDao dao = new ExcelRowDao();
		this.protoRowVo = new ExcelRowVo(dao.getColumnMappingList(conn));
	}
	
	public ArrayList getProtoCellList(){
		return protoRowVo!=null?protoRowVo.getRowCellList():null;
	}
	
	public ExcelRowVo createExcelRowVo()throws Exception{
		ExcelRowVo row = null;
		try {
			row = (ExcelRowVo)protoRowVo.clone();//new ExcelRowVo((ArrayList)getProtoCellList().clone());
		} catch (Exception e) {
			e.printStackTrace();
			Logger.logExceptions(e);
			throw e;
		}
		return row;
	}
}
